package com.ccg.service;

import com.ccg.dao.Order_Room_ItemDao;
import com.ccg.entity.Message;
import com.ccg.entity.Order_Room_Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Order_Room_ItemService {
    @Autowired
    Order_Room_ItemDao order_room_itemDao;

    //    根据订单增加一条消费记录
    public Message addRecord(Order_Room_Item order_room_item){
        int num;
        try {
            num = order_room_itemDao.addRecord(order_room_item);
        }catch (Exception e){
            return new Message(1,"添加失败","该订单的房间不存在");
        }
            if(num == 1){
                return new Message(0,"成功添加物品消费",null);
            }
            else return new Message(1,"添加失败","异常错误");
    }

    //根据订单ID查消费记录
    public Order_Room_Item findRecordById(int or_room_id) {
        return order_room_itemDao.findRecordById(or_room_id);
    }
    //根据订单ID删除一条消费记录
    public int deleteRecord(int ori_id) {
        return order_room_itemDao.deleteRecord(ori_id);
    }
    //消费记录ID验证
    public int ori_idCheck(int ori_id) {
        return order_room_itemDao.deleteRecord(ori_id);
    }
    //    根据记录ID修改信息
    public Message updateRecord(Order_Room_Item order_room_item){
            if(order_room_itemDao.updateRecord(order_room_item)>0){
                return new Message(0,"修改成功",null);
            }
            else return new Message(1,"修改失败","异常错误");
    }
}
